<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title>安全库存配置单查询</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="../../../lib/layui-v2.5.5/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
		<link rel="stylesheet" href="../../../css/public.css" media="all">
	</head>

	<body>
<div class="layuimini-container">
    <div class="layuimini-main">
		
		<!--搜索开始-->
		<fieldset class="layui-elem-field layuimini-search">
			<legend>搜索信息</legend>
			<div style="margin: 10px 10px 10px 10px">
				<form class="layui-form layui-form-pane" action="" id="searchFrm">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">产品名称</label>
							<div class="layui-input-inline">
								<input type="text" name="productName" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-inline">
							<a class="layui-btn " lay-submit="" lay-filter="data-search-btn"><label class="layui-icon layui-icon-search"></label>搜索</a>
							<a class="layui-btn layui-btn-warm" onclick="javascript:$('#searchFrm')[0].reset()" lay-filter="data-search-btn"><label
								 class="layui-icon layui-icon-refresh"></label>重置</a>
						</div>
					</div>
				</form>
			</div>
		</fieldset>
		<!--搜索结束-->
		
		<table id="RepertoryCell" lay-filter="test"></table>

		<!--修改的弹出层-->
		<div class="layui-row" id="update" style="display:none;">
			<div class="layui-col-md10" align="center">
				<form class="layui-form layui-from-pane" style="margin-top: 20px;" method="" id="accountFomat">
					<div class="layui-form-item"><label class="layui-form-label">配置单编号:</label>
						<div class="layui-input-block"><input type="text" name="storeId" id="storeId" autocomplete="off" placeholder="请输入产品编号"
							 class="layui-input">
						</div>
					</div>
					<div class="layui-form-item"><label class="layui-form-label">产品编号:</label>
						<div class="layui-input-block"><input type="text" name="productId" id="productId" autocomplete="off" placeholder="请输入产品编号"
							 class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label" style="width: 105px;">库存报警下限数:</label>
						<div class="layui-input-inline"><input type="text" name="minAmount" id="minAmount" autocomplete="off" placeholder="请输入库存报警下限数"
							 class="layui-input">
						</div>
						<label class="layui-form-label" style="width: 105px;">库存报警上限数:</label>
						<div class="layui-input-inline"><input type="text" name="maxAmount" id="maxAmount" autocomplete="off" placeholder="请输入库存报警上限数"
							 class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">设计人:</label>
						<div class="layui-input-inline"><input type="text" name="register" id="register" autocomplete="off" placeholder="请输入设计人"
							 class="layui-input">
						</div>
					</div>
					<table border="1px" bordercolor="#E6E6E6" width="800px" height="60px" style="margin-bottom: 20px; margin-left: 30px;">
						<tr align="center" bgcolor="#F2F2F2">
							<td>序号</td>
							<td>库房名称</td>
							<td>库存编号</td>
							<td>储存地址编号</td>
							<td>储存地址名称</td>
							<td>存储单元简称</td>
							<td>最大存储量</td>
							<td>存储单位</td>
						</tr>
						<tr align="center">
							<td id="pid"></td>
							<td id="storeName"></td>
							<td id="store_Id"></td>
							<td id="Kind"></td>
							<td id="type"></td>
							<td id="storageUnitShorted"></td>
							<td id="maxCapacityAmount"></td>
							<td id="amountUnit"></td>
						</tr>
					</table>
					<div class="layui-form-item">
						<label class="layui-form-label">复核人:</label>
						<div class="layui-input-inline"><input type="text" name="checker" id="checker" autocomplete="off" placeholder="请输入复核人"
							 class="layui-input">
						</div>
						<label class="layui-form-label">复核时间</label>
						<div class="layui-input-inline">
							<input type="text" class="layui-input" id="checkTime" name="checkTime" placeholder="yyyy-MM-dd">
						</div>
					</div>
					<div class="layui-form-item layui-form-text">
						<label class="layui-form-label">配置要求</label>
						<div class="layui-input-block">
							<textarea placeholder="请输入内容" class="layui-textarea" id="config" name="config"></textarea>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

		<script src="../../../lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
		<script src="../../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
		<script src="../../../lib/common/jquery.cookie.min.js" charset="utf-8"></script>
		<script src="../../../lib/common/common.js" charset="utf-8"></script>
		<script src="../../../lib/common/selectLayer.js" charset="utf-8"></script>
		<script src="../../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
		<script src="../../../lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>
		<script type="text/javascript">
			layui.use(['table', 'jquery', 'form','laydate'], function() {
				var table = layui.table,
					layer = layui.layer,
					form = layui.form,
					laydate=layui.laydate,
					$ = layui.jquery;

				var pid;
				var kind;
				var type;
				var productName;
				var registerTime;
				var storeId;
				var storageUnitShorted;
				var maxCapacityAmount;
				var amountUnit;
				var mainIndex;
				
				laydate.render({
				    elem: '#checkTime'
				 });
				
				//监听行工具事件
				table.on('tool(test)', function(obj) {
					var data = obj.data;
					//console.log(obj)
					if (obj.event === 'edit') {
						$("#storeId").val(data.storeId);
						$("#checkTime").val(data.checkTime);
						$("#checker").val(data.checker);
						$("#productId").val(data.productId);
						$("#minAmount").val(data.minAmount);
						$("#maxAmount").val(data.maxAmount);
						$("#register").val(data.register);
						$("#config").val(data.config);
						$("#productName").val(data.productName);
						$("#storeName").html(data.storeName);
						$("#store_Id").html(data.storeId);
						storeId=data.storeId;
						$("#storageUnitShorted").html(data.storageUnitShorted);
						storageUnitShorted=data.storageUnitShorted;
						$("#maxCapacityAmount").html(data.maxCapacityAmount);
						maxCapacityAmount=data.maxCapacityAmount;
						$("#amountUnit").html(data.amountUnit);
						amountUnit=data.amountUnit;
						$("#pid").html(data.id);
						pid = data.id;
						$("#Kind").html(data.firstKindId + "-" + data.secondKindId + "-" + data.thirdKindId);
						kind = data.firstKindId + "-" + data.secondKindId + "-" + data.thirdKindId;
						$("#type").html(data.firstKindName + "-" + data.secondKindName + "-" + data.thirdKindName);
						type = data.firstKindName + "-" + data.secondKindName + "-" + data.thirdKindName;

						mainIndex=layer.open({
							type: 1,
							title: '安全库存配置单审核',
							area: ['860px', '600px'],
							content: $("#update"),
							success: function(layero, index) {
								// 重新渲染弹层中的下拉选择框select
								form.render();
							}
						});

					}
				});
				
				// 监听搜索操作
				form.on('submit(data-search-btn)', function(data) {
					var params = $("#searchFrm").serialize();
					//执行搜索重载
					table.reload('RepertoryCell', {
						page: {
							curr: 1
						},
						url: api7 + 'RepertoryCell/getRepertoryCellAll?' + params
					});
					return false;
				});

				//第一个实例
				var tableIns=table.render({
					elem: '#RepertoryCell',
					url: api7 + 'RepertoryCell/getRepertoryCellAll' //数据接口
						,
					page: true //开启分页
						,
					cols: [
						[ //表头
							{
								field: 'storeId',
								title: '配置单单号',
								sort: true,
								fixed: 'left'
							}, {
								field: 'productId',
								title: '产品编号',
								sort: true,
								fixed: 'left'
							}, {
								field: 'productName',
								title: '产品名称'
							}, {
								field: 'type',
								title: '用途类型',
								templet: '#forType'
							}, {
								field: 'firstKindName',
								title: '一级分类'
							}, {
								field: 'secondKindName',
								title: '二级分类'
							}, {
								field: 'thirdKindName',
								title: '三级分类'
							}, {
								field: 'registerTime',
								title: '登记时间',
							}, {
								field: 'checkTag',
								title: '审核标志',
								templet: '#checkTag'
								
							}, {
								field: 'id',
								title: '操作',
								templet: '#formulate'
							}
						]
					]
				});

				//复核配置单
				form.on('submit(dataForm)', function(data) {
					$.ajax({
						url: api7 + "RepertoryCell/updRepertoryCell",
						method:"post",
						data: {
							productName: productName,
							id: pid,
							firstKindId: kind,
							firstKindName: type,
							productId: data.field.productId,
							minAmount: data.field.minAmount,
							maxAmount: data.field.maxAmount,
							storeId: storeId,
							register: data.field.register,
							registerTime: data.field.registerTime,
							storeName: $("#storeName").text(),
							storageUnitShorted: $("#storageUnitShorted").text(),
							maxCapacityAmount: $("#maxCapacityAmount").text(),
							amountUnit: $("#amountUnit").text(),
							config: data.field.config,
							checker: data.field.checker,
							checkTime: data.field.checkTime,
						},
						success:function(res) {
							if (res.code == 200) {
								layer.msg(res.msg);
								tableIns.reload();
							}
							layer.close(mainIndex);
						}
					})
				})

			});
		</script>
		<script type="text/html" id="forType">
			{{# if(d.type=='Y001-1'){d.type='商品'}}
				{{d.type}}
			{{# }else{d.type='物料'}}
				{{d.type}}
			{{# }}}
		</script>
		<script type="text/html" id="checkTag">
			{{# if(d.checkTag=='S001-1'){d.checkTag='等待审核'}}
				{{d.checkTag}}
			{{# }else if(d.checkTag=='S001-2'){d.checkTag='审核通过'}}
				{{d.checkTag}}
			{{# }else{d.checkTag='审核不通过'}}
				{{d.checkTag}}
			{{# }}}
		</script>
		<script type="text/html" id="formulate">
			<button class="layui-btn layui-btn-xs" lay-event="edit">查看详情</button>
		</script>
	</body>

</html>
